// src/utils/formatter.js
import dayjs from 'dayjs'

export const formatDate = (dateStr) => {
  if (!dateStr) return '-'
  return dayjs(dateStr).format('YYYY-MM-DD')
}

// 确保以下函数存在且正确导出
export const formatDateTime = (dateTimeStr) => {
  if (!dateTimeStr) return '-'
  return dayjs(dateTimeStr).format('YYYY-MM-DD HH:mm:ss')
}

export const formatCurrency = (amount) => {
  return '¥' + Number(amount).toLocaleString('zh-CN', { 
    minimumFractionDigits: 2,
    maximumFractionDigits: 2
  })
}

export const formatNumber = (num) => {
  return num ? Number(num).toFixed(2) : '0.00'
}